import socket

socket_server = socket.socket()
socket_server.bind(('localhost', 8888))

# 表示接受的连接数
socket_server.listen(1)

# accept是阻塞方法，直到连接
sock, addr = socket_server.accept()

print(f"接收到的客户端连接是：{addr}")

# 接收客户端的消息,
data = sock.recv(1024).decode('utf-8')
print(f"接收到的客户端消息是：{data}")

msg = input("请回复：").encode('utf-8')
# 发送消息
sock.send(msg)

# 关闭连接
# sock.close()
# socket_server.close()

# 网络助手地址
# https://github.com/nicedayzhu/netAssist/releases
